<template>
    <div class="DataItem">
        <div class="DataItem-title"  @click="toArticle()">{{ title }}</div>
        <div class="DataItem-abstract">{{ abstract }}</div>
            <div class="DataItem-tags">
                <span class="DataItem-tags-item"  v-for="(item,index) in tags" :key="index">
                {{ item }}
            </span>
        </div>
    </div>
</template>

<script setup>
    import {ref} from 'vue'  
    import { useRouter } from 'vue-router';


    const router = useRouter();
    const tags = ref(['python','c++'])
    const props = defineProps({
        id:{
            type:Number
        },
        title: {
            type: String,
            required: true
        },
        abstract: {
            type: String,
            required: true
        }
    })


    const toArticle = ()=>{
        router.push({
            name: 'article', // 使用路由名称
            params: { id: props.id } // 传递动态参数
      });

    }
</script>

<style lang="scss" scoped>
.DataItem{
    margin: 10px;
    display: flex;
    flex-direction: column;
    padding: 12px 20px 0;
    cursor: pointer;
    border-bottom: 1px solid rgba(228, 230, 235, 0.5);
    padding-bottom: 12px;
    &-title{
        font-size: 20px;
        font-weight: 600;
        line-height: 24px;
        color: #252933;
        margin-bottom: 10px;
    }
    &-abstract{
        color: #8a919f;
        font-size: 13px;
        line-height: 22px;
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 10px;
    }
    &-tags{
        display: flex;
        flex-direction: row;
        align-items: center;
        &-item{
            margin: 10px;
            padding: 3px;
            border-radius: 8px;
            font-size: 13px;
            border: 0.5px solid rgba(0, 0, 0, .3);
        }
    }   


}
</style>